//ComponentMessenger.h

#pragma once
#ifndef COMPONENT_MESSENGER_H_INCLUDED
#define COMPONENT_MESSENGER_H_INCLUDED

#include "ComponentsPrereq.h"
namespace ne{
class ComponentMessenger{
public:
	ComponentMessenger(){}
	~ComponentMessenger(){}
	void Register(IComponentObserver* ob){m_obs.push_back(ob);}
	void Unregister(IComponentObserver* ob){
		auto it = std::find(m_obs.begin(),m_obs.end(),ob);
		if (it!=m_obs.end()){
			m_obs.erase(it);
		}
	}
	void Notify(CEvent* msg){
		for (unsigned int i=0;i<m_obs.size();i++){
			m_obs[i]->Notify(msg);
		}
	}
private:
	std::vector<IComponentObserver*> m_obs;
};

} // namespace ne

#endif // COMPONENT_MESSENGER_H_INCLUDED